package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.crop.api.domain.Warehouse;
import com.ruoyi.system.api.RemoteCropService;
import lombok.extern.java.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 文件服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteCropFallbackFactory implements FallbackFactory<RemoteCropService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteCropFallbackFactory.class);

    @Override
    public RemoteCropService create(Throwable throwable) {
        log.error("农作物服务调用失败: {}", throwable.getMessage());

        return new RemoteCropService() {
            @Override
            public AjaxResult FeignList() {
                return AjaxResult.warn("获取农作物列表失败");
            }

            @Override
            public List<Long> FeignWarehouseById(Long userId) {
                return null;
            }

            @Override
            public AjaxResult selectWarehouseList() {
                return AjaxResult.warn("获取仓库列表失败");
            }


            @Override
            public AjaxResult FeignWarehouseById(Long userId, Long[] warehouseIds) {
                return AjaxResult.warn("获取仓库失败");
            }
        };
    }
}
